package de.sendorian.app.forumArchive.renamer;

import de.sendorian.app.forumArchive.domain.File;
import de.sendorian.app.forumArchive.domain.Post;
import de.sendorian.app.forumArchive.repository.FileRepositoryImpl;


public class AppendUserShortnameRenamer implements FileRenamer {

    public AppendUserShortnameRenamer() {
    }


    public File rename(File file) {
        Post post = new FileRepositoryImpl().findPostByFile(file);
        if (post != null) {
            // FIXME as long as files in archives are not renamed this causes
            // duplicates!
            // file.checkAndCorrectAuthorAppendix();
            file.appendUserShortname(post.getAuthor().getShortName());
        }
        return file;
    }
}
